<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>拍品审核列表</title>
    <script src="/common/js/jquery.min.js" type="text/javascript"></script>
    <script src="/common/layui/layui.js" type="text/javascript"></script>
    <script src="/common/layui/layui.all.js" type="text/javascript"></script>
    <script src="/common/js/userServer.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/common/layui/css/layui.css">
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">审核数据列表</button>
        <!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
        <!--        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    {{# if(d.state == "1" && d.aucstate != "2"){ }}
    <a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
    {{#  } }}
</script>
<script src="/common/js/jquery-2.1.4.js" charset="utf-8"></script>
<script src="/common/layui/layui.js" charset="utf-8"></script>
<script src="/common/js/userServer.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    var col = [
        {type: 'checkbox', fixed: 'left'}
        , {field: 'sid', title: 'ID', sort: true}
        , {field: 'sname', title: '拍品名称'}
        , {field: 'cou', title: '数量'}
        , {field: 'price', title: '起拍价'}
        , {field: 'start', title: '起拍时间'}
        , {field: 'end', title: '截止时间'}
        , {field: 'bzjzfzt', title: '保证金支付状态'}
        , {field: 'states', title: '审核状态'}
        ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
    ];
    layui.use('table', function () {
        var table = layui.table;

        table.render({
            elem: '#test'
            , url: '/getData/queryShopping'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , page: true
            , height:615
            ,request: {
                pageName: 'curr' //页码的参数名称，默认：page
                ,limitName: 'nums' //每页数据量的参数名，默认：limit
            }
            ,defaultToolbar: ['filter']
            ,title: '类型数据表'
            , cols: [
                col
            ]
        });
        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：'+ data.length + ' 个');
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选': '未全选');
                    break;

                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(data)
            if(obj.event === 'detail'){
                var sid =data.sid;
                layer.open({
                    type: 2,
                    area: ['1000px', '700px'],
                    skin: 'layui-layer-rim', //加上边框
                    // btn: ['关闭','false'],
                    shadeClose:true,
                    content: ["/goods/openGoodsDetailView.do?sid="+sid, 'no'],
                    success:function(layero,index) {
                        static_index = index;
                        var iframe = window['layui-layer-iframe' + index];
                        iframe.child("audit");
                    }
                });
            } else if(obj.event === 'edit'){
                if(data.state==1){
                    layer.open({
                        time: 6000  //1秒=1000
                        ,btn: ['通过', '不通过', '取消']
                        ,yes: function(index, layero){
                            var param = {};
                            param.sid = data.sid;
                            param.state = 2;
                            Base.requestServer("toExamine",param,function (data) {
                                if(data==1){
                                    layer.msg("审核成功");
                                }else {
                                    layer.msg("审核失败，稍后再试");
                                }

                            });
                        }
                        ,btn2: function(index, layero){
                            var param = {};
                            param.sid = data.sid;
                            param.state = 3;
                            Base.requestServer("toExamine",param,function (data) {
                                if(data==1){
                                    layer.msg("审核成功");
                                }else {
                                    layer.msg("审核失败，稍后再试");
                                }
                            })
                        }
                        ,btn3: function(index, layero){
                            //按钮【按钮三】的回调
                            //return false 开启该代码可禁止点击该按钮关闭
                        }
                    });
                    setTimeout(function () {
                        window.location.reload();
                    },3000);
                }else if(data.state==2){
                    layer.msg("该商品已审核通过不可再进行审核操作");
                }else {
                    layer.msg("该商品不可再进行审核操作")
                }
            }
        });
    });
</script>

</body>
</html>